<?php

namespace App\baocaitong3\Util;
class Log
{
    public static function LogWirte($Astring)
    {
        $path = $_SERVER['DOCUMENT_ROOT'];
        $path = $path . "/log/";
        $file = $path . "log" . date('Ymd', time()) . ".txt";
        if (!is_dir($path)) {
            mkdir($path);
        }
        $LogTime = date('Y-m-d H:i:s', time());
        if (!file_exists($file)) {
            $logfile = fopen($file, "w") or die("Unable to open file!");
            fwrite($logfile, "[$LogTime]:" . $Astring . "\r\n");
            fclose($logfile);
        } else {
            $logfile = fopen($file, "a") or die("Unable to open file!");
            fwrite($logfile, "[$LogTime]:" . $Astring . "\r\n");
            fclose($logfile);
        }
    }

    public static function EchoFormat($Astring)
    {
        $LogTime = date('Y-m-d H:i:s', time());
        echo $LogTime . " " . $Astring . "<br>";
    }
}